package com.imis.module.websocket.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.imis.base.globle.Result;
import com.imis.module.base.BaseController;
import com.imis.module.system.model.vo.SysWebsocketMessageInfoVO;
import com.imis.module.websocket.bus.InstantMessagingBus;
import com.imis.module.websocket.dto.PagingQueryMessageDTO;
import com.imis.module.websocket.dto.WebSocketMessageDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * InstantMessagingController<br>
 * 即时通讯 前端控制器
 * </p>
 *
 * @author XinLau
 * @version 1.0
 * @since 2020年07月24日 17:43
 */
@Slf4j
@RestController
@RequestMapping("/sys/messaging")
@Api(tags = {"即时通讯"})
@ApiSort(1)
public class InstantMessagingController extends BaseController<InstantMessagingBus> {

    @RequestMapping(value = "/queryOnlineNumber", method = RequestMethod.GET)
    @ApiOperation(value = "查询在线人数接口", notes = "查询在线人数接口")
    @ApiOperationSupport(order = 1, author = "XinLau")
    public Result queryOnlineNumber() {
        return service.queryOnlineNumber();
    }

    @RequestMapping(value = "/pagingQueryHistoricalMassages", method = RequestMethod.POST)
    @ApiOperation(value = "查看历史消息接口", notes = "查看指定好友的历史消息接口")
    @ApiOperationSupport(order = 2, author = "XinLau")
    public Result<Page<SysWebsocketMessageInfoVO>> pagingQueryHistoricalMassages(@RequestBody PagingQueryMessageDTO pagingQueryMessageDTO) {
        return service.pagingQueryHistoricalMassages(pagingQueryMessageDTO);
    }

    @RequestMapping(value = "/sendMassage", method = RequestMethod.POST)
    @ApiOperation(value = "发送消息接口", notes = "发送消息接口")
    @ApiOperationSupport(order = 3, author = "XinLau")
    public Result sendMassage(@RequestBody WebSocketMessageDTO webSocketMessage) {
        return service.sendMassage(webSocketMessage);
    }

}
